package cc.ailley.singleton.serialize;

import java.io.Serializable;

/**
 * 饿汉式(线程安全)
 *
 * @author ailley
 */
public class Serialize implements Serializable{

    private Serialize(){}

    private final static Serialize instance = new Serialize();

    public static Serialize getInstance(){
        return instance;
    }

    /**
     * 使用该方法来保证序列化和反序列化后的对象是单例对象
     *
     * @return
     */
    private Object readResolve(){
        return instance;
    }
}
